<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>ES7  对Promise的优化 async</title>
</head>
<body>

    <script>
        //关键词 async  返回值Promise对象
        async function task1(){
            return 'task1 ...执行成功';
        }
        console.log(task1());//Promise对象
        async function task2(){
            return 'task2 ...执行成功';
        }
        async function task3(){
            return 'task3 ...执行成功';
        }
        //es6
        task1().then((data)=>{
            console.log("es6处理数据"+data);
        })
        //es7   await 简化 then()   注:使用await必须有async修饰函数
        async function test(){
            let ret1=await task1();
            console.log('es7-->'+ret1);
            let ret2=await task2();
            console.log('es7-->'+ret2);
            let ret3=await task3();
            console.log('es7-->'+ret3);
        }
        test();    
    </script>
</body>
</html>